var companyId = 8522;
var kf_openurl="http://chat.5251.net/client.jsp?flag=1&companyId=8522&style=18846&locate=en" +"&refer="+ escape(window.location.href)+"&username="+encodeURIComponent("")+"&conn_word="+encodeURIComponent("");

var route = escape(window.location.href);

var kdocTitle = document.title;
if(kdocTitle == null){
 var t_titles = document.getElementByTagName("title")
 if(t_titles && t_titles.length >0)
 {
 kdocTitle = t_titles[0];
 }else{
 kdocTitle = "";
 }
}

function setCookie(name, value, path, domain) {
 var oCookie = name + "=" + escape(value) +
 "; expires=Thu, 6 Jan 2100 12:01:01 UTC" +
 ((path) ? "; path=" + path : "") +
 ((domain) ? "; domain=" + domain : "");
 document.cookie = oCookie;
}

function getCookie(name) {
 var dc = document.cookie;
 var prefix = name + "=";
 var begin = dc.indexOf("; " + prefix);
 if (begin == -1) {
 begin = dc.indexOf(prefix);
 if (begin != 0) return "";
 } else
 begin += 2;
 var end = document.cookie.indexOf(";", begin);
 if (end == -1)
 end = dc.length;
 return unescape(dc.substring(begin + prefix.length, end));
}

var now = new Date();
var ss = now.getTime()

var temp_d = parseInt(Math.random() *10000);
var user_str = "" + ss + "_" + temp_d;

var userid = getCookie("kf51_userid");
if(userid == "" || userid == null)
{

 setCookie("kf51_userid",user_str);
 userid = user_str ;
}

//alert("userid is-->" + getCookie("kf51_userid"));
var ref = document.referrer;
var local_host = document.domain;

var globalWindowAttr = 'height=473,width=703,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,titlebar=no';

if(ref.indexOf(local_host) < 0)
{
 setCookie("kf51_referrer",ref);
}
kf_openurl += "&keyword="+escape(getCookie("kf51_referrer"));
kf_openurl += "&userid="+userid;
function open_pic_chat()
{
 var chat_win= window.open(kf_openurl,'chat_8522',globalWindowAttr);
 chat_win.focus();
 try{sendAndRecieve("/js/recieve.jsp?state=4&companyId="+8522+"&sessionId="+userid);}catch(e){}
}
function open_chat_person(workerid)
{
 var chat_win = window.open(kf_openurl+'&workId='+workerid+'&flag=3','chat_8522',globalWindowAttr);
 chat_win.focus();
 try{sendAndRecieve("/js/recieve.jsp?state=4&companyId="+companyId+"&sessionId="+userid);}catch(e){}
}
var is_kf_online = 1;
var kf_workids = ",8522,21234,";
var workids = ",8522,21234,";
var judge_kf_isonline = function(workerid){
 if(kf_workids.indexOf(","+workerid+",")>-1)return true;
 else return false;
}

//kf_openurl="http://chat.5251.net/client.jsp?flag=1&companyId=8522&style=18846&locate=en" +"&refer="+ escape(window.location.href);
document.write("<div class=\"livehelp spbg\"><a href='javascript:;' onclick=\"open_pic_chat()\">Live Chat</a></div>");
var onloadInterval_fixed = window.setInterval(show_fixed_kf,500);
function show_fixed_kf()
{

 try{showKFDiv()}catch(e){};

}


function y_gVal(iz)
{var endstr=document.cookie.indexOf(";",iz);if(endstr==-1) endstr=document.cookie.length;return document.cookie.substring(iz,endstr);}
function y_g(name)
{var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i=0;var j;while(i<clen) {j=i+alen;if(document.cookie.substring(i,j)==arg) return y_gVal(j);i=document.cookie.indexOf(" ",i)+1;if(i==0) break;}return null;}
function cc_k()
{var y_e=new Date();var y_t=31104000000;var yesvisitor=1000*3600*24;var yesctime=y_e.getTime();y_e.setTime(y_e.getTime()+y_t);var yesiz=document.cookie.indexOf("cck_lasttime");if(yesiz==-1){document.cookie="cck_lasttime="+yesctime+"; expires=" + y_e.toGMTString() + "; path=/";document.cookie="cck_count=0; expires=" + y_e.toGMTString() + "; path=/";return 0;}else{var y_c1=y_g("cck_lasttime");var y_c2=y_g("cck_count");y_c1=parseInt(y_c1);y_c2=parseInt(y_c2);y_c3=yesctime-y_c1;if(y_c3>yesvisitor){y_c2=y_c2+1;document.cookie="cck_lasttime="+yesctime+"; expires="+y_e.toGMTString()+"; path=/";document.cookie="cck_count="+y_c2+"; expires="+y_e.toGMTString()+"; path=/";}return y_c2;}}
var yesdata;
yesdata='companyId=8522&userid='+userid+'&refe='+escape(document.referrer)+'&location='+escape(document.location)+'&color='+screen.colorDepth+'x&resolution='+screen.width+'x'+screen.height+'&returning='+cc_k()+'&language='+navigator.systemLanguage+'&ua='+escape(navigator.userAgent)+'&ip=';
var host_stat = document.domain;
var refe_stat = document.referrer;
if(refe_stat == null)refe_stat= "";
var pos = refe_stat.indexOf(host_stat);

if( refe_stat == "" || pos == -1 )
{
 js_src = "http://stat1.5251.net/stat.jsp?" +yesdata;

 var script=document.createElement("script");
 script.type='text/javascript';
 script.language='javascript';
 script.src=js_src;
 document.getElementsByTagName("head")[0].appendChild(script);
} 